<?php
/**
 * Created by PhpStorm.
 * User: BesonTD
 * Date: 15-1-31
 * Time: 下午1:42
 * 订阅相关程序
 */


if (!defined('APP_IN')) exit('Access Denied');

if (!defined('RAIDERS_SIGN')) define('RAIDERS_SIGN', 'mycars');

if (!isset($_GET['sign']) || $_GET['sign'] != RAIDERS_SIGN) return false;

include (INC_DIR . 'Umeng.class.php');
$Umeng = new Umeng();


$sql = "SELECT r.mid,r.number,m.device FROM (SELECT mid,sum(number) as number FROM {$db_config['TB_PREFIX']}rule_count GROUP BY mid HAVING number >0) as r LEFT JOIN {$db_config['TB_PREFIX']}member as m ON r.mid=m.id";
$result = $db->row_query($sql);
if($result){
    foreach($result as $v){
        if($v['device']){
            //android
            $Umeng->sendAndroidUnicast(array('ticker'=>'车源订阅','title'=>'新车源提醒','content'=>'您的订阅车源新纪录数：'.$v['number']),$v['device']);
            //ios
            $Umeng->sendIOSUnicast(array('raiders'=>'订阅车源新纪录数：'.$v['number']),$v['device']);
        }
    }
}

return false;

